package com.chushouya.manager.dao.repository;

import com.chushouya.manager.dao.entity.PartnerRuleEntity;
import com.chushouya.manager.dao.mapper.PartnerRuleEntityMapper;
import com.general.framework.core.enums.StatusEnum;
import com.general.framework.data.mybatis.BaseRepository;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Repository
public class PartnerRulesRepository extends BaseRepository<PartnerRuleEntityMapper, PartnerRuleEntity, Long> {
    public PartnerRuleEntity selectByPartnerId(Long partnerId) {
        Example example = new Example(PartnerRuleEntity.class);
        example.createCriteria().andEqualTo("partnerId", partnerId);
        return this.selectFirstOneByExample(example);
    }

    /**
     * 获取全部合作商的规则
     */
    public List<PartnerRuleEntity> selectAllPartnerRules() {
        Example example = new Example(PartnerRuleEntity.class);
        example.createCriteria().andEqualTo("status", StatusEnum.normal.value());
        return this.selectByExample(example);
    }
}
